package nl.vu.few.ibivu.biomodels.client.event;


import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;

public class MessageBroadcastEvent extends GwtEvent<MessageBroadcastEventHandler> {

	public static Type<MessageBroadcastEventHandler> TYPE = new Type<MessageBroadcastEventHandler>();

	private MessageBroadcastType type;
	private String message;
	
	public MessageBroadcastEvent(MessageBroadcastType type, String message) {
		super();
		this.type = type;
		this.message = message;
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<MessageBroadcastEventHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(MessageBroadcastEventHandler handler) {
		handler.onMessageReceived(this);
	}

	public static HandlerRegistration register(EventBus eventBus, MessageBroadcastEventHandler handler) {
		return eventBus.addHandler(TYPE, handler);
	}

	public MessageBroadcastType getMessageType() {
		return type;
	}
	
	public String getMessage() {
		return message;
	}

}
